package com.eastfair.pay.entity;

import cn.afterturn.easypoi.excel.annotation.Excel;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.eastfair.annotation.model.EchoVO;
import com.eastfair.core.base.entity.Entity;
import com.eastfair.pay.enumeration.TransactionOrderOrderStatusEnum;
import com.eastfair.pay.enumeration.TransactionOrderOrderTypeEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;

import javax.validation.constraints.Size;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;

import static com.baomidou.mybatisplus.annotation.SqlCondition.LIKE;
import static com.eastfair.core.utils.DateUtils.DEFAULT_DATE_TIME_FORMAT;

/**
 * <p>
 * 实体类
 * 交易订单
 * </p>
 *
 * @author fwl
 * @since 2023-03-22
 */
@Data
@NoArgsConstructor
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("pay_transaction_order")
@ApiModel(value = "TransactionOrder", description = "交易订单")
@AllArgsConstructor
public class TransactionOrder extends Entity<Long> implements EchoVO {

    private static final long serialVersionUID = 1L;
    @TableField(exist = false)
    private Map<String, Object> echoMap = new HashMap<>();
    /**
     * 是否启用：1是；0否
     */
    @ApiModelProperty(value = "是否启用：1是；0否")
    @TableField(value = "is_enabled")
    @Excel(name = "是否启用：1是；0否")
    private Integer isEnabled;

    /**
     * 是否删除：1是；0否
     */
    @ApiModelProperty(value = "是否删除：1是；0否")
    @TableField(value = "is_deleted")
    @Excel(name = "是否删除：1是；0否")
    private Integer isDeleted;

    /**
     * 项目id
     */
    @ApiModelProperty(value = "项目id")
    @TableField(value = "project_id")
    @Excel(name = "项目id")
    private Long projectId;

    /**
     * 子系统id
     */
    @ApiModelProperty(value = "子系统id")
    @TableField(value = "subsystem_id")
    @Excel(name = "子系统id")
    private Long subsystemId;

    /**
     * 租户id
     */
    @ApiModelProperty(value = "租户id")
    @TableField(value = "tenant_id")
    @Excel(name = "租户id")
    private Long tenantId;

    /**
     * 展会名称
     */
    @ApiModelProperty(value = "展会名称")
    @Size(max = 255, message = "展会名称长度不能超过255")
    @TableField(value = "exhibition_name", condition = LIKE)
    @Excel(name = "展会名称")
    private String exhibitionName;

    /**
     * 展会id
     */
    @ApiModelProperty(value = "展会id")
    @TableField(value = "exhibition_id")
    @Excel(name = "展会id")
    private Long exhibitionId;

    /**
     * 业务类型:#{CONTRACT:合同;SERVICE:服务;CERTIFICATE:证件;WORKEXTRA:加班;FINE:罚款;BOND:保证金;EXHIBITION:展览;MEETING:会议;FOOD:餐饮;SETTLEMENT:结算单}
     */
    @ApiModelProperty(value = "业务类型:#{CONTRACT:合同;SERVICE:服务;CERTIFICATE:证件;WORKEXTRA:加班;FINE:罚款;BOND:保证金;EXHIBITION:展览;MEETING:会议;FOOD:餐饮;SETTLEMENT:结算单}")
    @TableField(value = "order_type")
    @Excel(name = "业务类型:#{CONTRACT:合同;SERVICE:服务;CERTIFICATE:证件;WORKEXTRA:加班;FINE:罚款;BOND:保证金;EXHIBITION:展览;MEETING:会议;FOOD:餐饮;SETTLEMENT:结算单}", replace = {"合同_CONTRACT", "服务_SERVICE", "证件_CERTIFICATE", "加班_WORKEXTRA", "罚款_FINE", "保证金_BOND", "展览_EXHIBITION", "会议_MEETING", "餐饮_FOOD", "结算单_SETTLEMENT", "_null"})
    private TransactionOrderOrderTypeEnum orderType;

    /**
     * 订单名称
     */
    @ApiModelProperty(value = "订单名称")
    @Size(max = 255, message = "订单名称长度不能超过255")
    @TableField(value = "order_name", condition = LIKE)
    @Excel(name = "订单名称")
    private String orderName;

    /**
     * 单号
     */
    @ApiModelProperty(value = "单号")
    @Size(max = 255, message = "单号长度不能超过255")
    @TableField(value = "order_num", condition = LIKE)
    @Excel(name = "单号")
    private String orderNum;

    /**
     * 单额
     */
    @ApiModelProperty(value = "单额")
    @TableField(value = "order_amount")
    @Excel(name = "单额")
    private BigDecimal orderAmount;

    /**
     * 订单时间
     */
    @ApiModelProperty(value = "订单时间")
    @TableField(value = "order_time")
    @Excel(name = "订单时间", format = DEFAULT_DATE_TIME_FORMAT, width = 20)
    private LocalDateTime orderTime;

    /**
     * 支付状态:#{PAYING:支付中;UNPAY:未付款;PAYED:已付款;PARTPAY:部分分款;REFUNDING:退款中;REFUNDED:已退款}
     */
    @ApiModelProperty(value = "支付状态:#{PAYING:支付中;UNPAY:未付款;PAYED:已付款;PARTPAY:部分分款;REFUNDING:退款中;REFUNDED:已退款}")
    @TableField(value = "order_status")
    @Excel(name = "支付状态:#{PAYING:支付中;UNPAY:未付款;PAYED:已付款;PARTPAY:部分分款;REFUNDING:退款中;REFUNDED:已退款}", replace = {"支付中_PAYING", "未付款_UNPAY", "已付款_PAYED", "部分分款_PARTPAY", "退款中_REFUNDING", "已退款_REFUNDED",  "_null"})
    private TransactionOrderOrderStatusEnum orderStatus;

    /**
     * 订单状态
     * {@link com.eastfair.pay.enums.OrderStateEnum}
     */
    @ApiModelProperty(value = "订单状态")
    @TableField(value = "state")
    @Excel(name = "订单状态")
    private Integer state;

    /**
     * 付款计划
     */
    @ApiModelProperty(value = "付款计划")
    @Size(max = 255, message = "付款计划长度不能超过255")
    @TableField(value = "payment_plan", condition = LIKE)
    @Excel(name = "付款计划")
    private String paymentPlan;

    /**
     * 付款期数
     */
    @ApiModelProperty(value = "付款期数")
    @TableField(value = "payment_periods")
    @Excel(name = "付款期数")
    private Integer paymentPeriods;

    /**
     * 系统标识
     */
    @ApiModelProperty(value = "系统标识")
    @Size(max = 255, message = "系统标识长度不能超过255")
    @TableField(value = "system_scene", condition = LIKE)
    @Excel(name = "系统标识")
    private String systemScene;

    /**
     * 付款方
     */
    @ApiModelProperty(value = "付款方")
    @Size(max = 255, message = "付款方长度不能超过255")
    @TableField(value = "payer", condition = LIKE)
    @Excel(name = "付款方")
    private String payer;

    /**
     * 收款单位
     */
    @ApiModelProperty(value = "收款单位")
    @Size(max = 255, message = "收款单位长度不能超过255")
    @TableField(value = "payee", condition = LIKE)
    @Excel(name = "收款单位")
    private String payee;

    /**
     * 商户系统名称
     */
    @ApiModelProperty(value = "商户系统名称")
    @Size(max = 255, message = "商户系统名称长度不能超过255")
    @TableField(value = "system_name", condition = LIKE)
    @Excel(name = "商户系统名称")
    private String systemName;

    /**
     * 商户系统标识
     */
    @ApiModelProperty(value = "商户系统标识")
    @Size(max = 255, message = "商户系统标识长度不能超过255")
    @TableField(value = "system_code", condition = LIKE)
    @Excel(name = "商户系统标识")
    private String systemCode;

    /**
     * 支付方式
     */
    @ApiModelProperty(value = "支付方式")
    @Size(max = 255, message = "支付方式长度不能超过255")
    @TableField(value = "pay_type", condition = LIKE)
    @Excel(name = "支付方式")
    private String payType;

    /**
     * 交易流水号
     */
    @ApiModelProperty(value = "交易流水号")
    @Size(max = 255, message = "交易流水号长度不能超过255")
    @TableField(value = "pay_order_no", condition = LIKE)
    @Excel(name = "交易流水号")
    private String payOrderNo;


    /**
     * 付款时间
     */
    @ApiModelProperty(value = "付款时间")
    @Size(max = 255, message = "付款时间")
    @TableField(value = "payment_time")
    @Excel(name = "付款时间")
    private LocalDateTime paymentTime;

    /**
     * 制单流水号
     */
    @ApiModelProperty(value = "制单流水号")
    @Size(max = 255, message = "制单流水号长度不能超过255")
    @TableField(value = "mainno", condition = LIKE)
    @Excel(name = "制单流水号")
    private String mainno;

    /**
     * 支付渠道
     */
    @ApiModelProperty(value = "支付渠道")
    @Size(max = 255, message = "支付渠道长度不能超过255")
    @TableField(value = "pay_channel", condition = LIKE)
    @Excel(name = "支付渠道")
    private String payChannel;


    @Builder
    public TransactionOrder(Long id, Long createdBy, LocalDateTime createTime, Long updatedBy, LocalDateTime updateTime, 
                    Integer isEnabled, Integer isDeleted, Long projectId, Long subsystemId, Long tenantId, 
                    String exhibitionName, Long exhibitionId, TransactionOrderOrderTypeEnum orderType, String orderName, String orderNum, BigDecimal orderAmount, 
                    LocalDateTime orderTime, TransactionOrderOrderStatusEnum orderStatus, String paymentPlan, Integer paymentPeriods, String systemScene, String payer, 
                    String payee, String systemName, String systemCode, String payType, String payOrderNo, String mainno) {
        this.id = id;
        this.createdBy = createdBy;
        this.createTime = createTime;
        this.updatedBy = updatedBy;
        this.updateTime = updateTime;
        this.isEnabled = isEnabled;
        this.isDeleted = isDeleted;
        this.projectId = projectId;
        this.subsystemId = subsystemId;
        this.tenantId = tenantId;
        this.exhibitionName = exhibitionName;
        this.exhibitionId = exhibitionId;
        this.orderType = orderType;
        this.orderName = orderName;
        this.orderNum = orderNum;
        this.orderAmount = orderAmount;
        this.orderTime = orderTime;
        this.orderStatus = orderStatus;
        this.paymentPlan = paymentPlan;
        this.paymentPeriods = paymentPeriods;
        this.systemScene = systemScene;
        this.payer = payer;
        this.payee = payee;
        this.systemName = systemName;
        this.systemCode = systemCode;
        this.payType = payType;
        this.payOrderNo = payOrderNo;
        this.mainno = mainno;
    }

}
